package com.gitee.ixtf.vertx.kotlinx

import graphql.schema.DataFetchingEnvironment
import kotlin.reflect.KClass
import org.dataloader.BatchLoader
import org.dataloader.MappedBatchLoader
import org.dataloader.MappedBatchPublisher

fun <K : Any, V : Any> DataFetchingEnvironment.dataLoader(
    clazz: KClass<out MappedBatchPublisher<K, V>>
) = getDataLoader<K, V>(clazz.java.name)!!

fun <K : Any, V : Any> DataFetchingEnvironment.dataLoader(
    clazz: Class<out MappedBatchLoader<K, V>>
) = getDataLoader<K, V>(clazz.name)!!

fun <K : Any, V : Any> DataFetchingEnvironment.batchLoader(clazz: Class<out BatchLoader<K, V>>) =
    getDataLoader<K, V>(clazz.name)!!
